<?php
/**
 * Created by PhpStorm.
 * User: Thans
 * Date: 2018/1/3
 * Time: 下午2:13
 */

namespace app\admin\validate;

use think\Validate;

class UserValidate extends Validate
{
    protected $rule = [
        'user_login' => 'require|min:3|max:12',
        'user_pass' => 'require|min:6|max:16',
        'user_email' => 'email',
        'old_pass' => 'require|min:6|max:16',
        'confirm_user_pass' => 'require|confirm:user_pass',
        'mobile' => 'mobile',
        'user_url' => 'url',
        'sex'=>'number|between:0,2'
    ];

    protected $message = [
        'user_login.require' => '请输入手机号\用户名\邮箱!',
        'user_login.min' => '用户名不能长度不能小于3',
        'user_login.max' => '用户名不能长度不能大于12',
        'user_pass.require' => '请输入您的密码!',
        'user_email.email' => '请输入正确的邮箱',
        'user_email.require' => '请输入邮箱',
        'old_pass.require' => '旧密码不能为空',
        'confirm_user_pass' => '两次输入密码不一致',
        'mobile.mobile' => '请输入正确的手机号码',
        'sex.number' => '请正确选择性别',
        'user_url.url' => '请正确的网址'
    ];

    protected $scene = [
        'user_login'  => ['user_login','user_pass'],
        'update_admin_without_pass' => ['user_login','user_email'],
        'update_admin_with_pass' => ['user_login','user_pass','user_email'],
        'add_admin' => ['user_login','user_pass','user_email'],
        'admin_edit_user' => ['user_login'],
        'update_self_pass' => ['user_pass','old_pass','confirm_user_pass'],
        'update_self_user' => ['user_email','sex']
    ];
}